package thired.algorithm;

import java.util.Arrays;
import java.util.Scanner;

public class shou {

    public static void fight(int u, int v, boolean c1, boolean c2, boolean[] alive, boolean[] cos, int[] activity){
        if(!alive[u]||!alive[v]){
            return;
        }


        if(!c1 && !c2){
            return;
        }

        if(cos[u] == cos[v]){
            return;
        }


        if((!cos[u] && cos[v] && c2) || (!cos[v] && cos[u] && c1)){
            if(activity[u] == activity[v]){
                alive[u] = false;
                alive[v] = false;
            }
            if(activity[u] > activity[v]){
                alive[v] = false;
            }
            if(activity[v] > activity[u]){
                alive[u] = false;
            }
        }

        if((!cos[u] && cos[v] && c1) || (!cos[v] && cos[u] && c2)){
            int human = cos[u] ? u : v;
            int master = human == u ? v : u;
            if(activity[human] > activity[master]){
                alive[master] = false;
            }
        }

    }



    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] cos = new boolean[n];// fales manster true human
        if(n != 0 || m != 0)
        {
            sc.nextLine();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                String[] s = sc.nextLine().split(" ");
                cos[i] =  s[0].equals("human");
                a[i] = Integer.parseInt(s[1]);
            }
            boolean[] alive = new boolean[n];
            Arrays.fill(alive,true);
            for (int i = 0; i < m; i++) {
                String[] s = sc.nextLine().split(" ");
                int u = Integer.parseInt(s[0]) - 1;
                int v = Integer.parseInt(s[1]) - 1;
                boolean c1 = s[2].equals("Y");
                boolean c2 = s[3].equals("Y");
                fight(u,v,c1,c2,alive,cos,a);
            }
            for (int i = 0; i < n; i++) {
                if(alive[i]){
                    System.out.print("Y");
                }else{
                    System.out.print("N");
                }
            }

        }
    }

}


